package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.T10VO;
import com.ruoyi.common.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T10;
import com.ruoyi.service.IT10Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充值记录Controller
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
@RestController
@RequestMapping("/payrecord/record")
public class T10Controller extends BaseController
{
    @Autowired
    private IT10Service t10Service;

    /**
     * 查询充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(T10 t10)
    {
        startPage();
        List<T10> list = t10Service.selectT10List(t10);
        return getDataTable(list);
    }

    /**
     * 导出充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:export')")
    @Log(title = "充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T10 t10)
    {
        List<T10> list = t10Service.selectT10List(t10);
        ExcelUtil<T10> util = new ExcelUtil<T10>(T10.class);
        util.exportExcel(response, list, "充值记录数据");
    }

    /**
     * 获取充值记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:query')")
    @GetMapping(value = "/{F1001}")
    public AjaxResult getInfo(@PathVariable("F1001") Long F1001)
    {
        return success(t10Service.selectT10ByF1001(F1001));
    }

    /**
     * 新增充值记录
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:add')")
    @Log(title = "充值记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody T10 t10)
    {
        return toAjax(t10Service.insertT10(t10));
    }

    /**
     * 修改充值记录
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:edit')")
    @Log(title = "充值记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T10 t10)
    {
        return toAjax(t10Service.updateT10(t10));
    }

    /**
     * 删除充值记录
     */
    @PreAuthorize("@ss.hasPermi('payrecord:record:remove')")
    @Log(title = "充值记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F1001s}")
    public AjaxResult remove(@PathVariable Long[] F1001s)
    {
        return toAjax(t10Service.deleteT10ByF1001s(F1001s));
    }

    @GetMapping("/getPayRecords")
    @ApiOperation("公司充值记录")
    public Result getPayRecords(Long F0301) throws  Exception{
        if (F0301 == null){
            return new Result("参数错误");
        }
        List<T10VO> list = t10Service.getPayRecords(F0301);
        if (list.size() == 0){
            return new Result("没有充值记录");
        }
        return Result.success(list,"success");
    }

    @GetMapping("/getPAyRecordPeople")
    @ApiOperation("充值人")
    public Result getPAyRecordPeople(Long F0601) throws Exception{
        if (F0601 == null){
            return new Result("参数错误");
        }
        List<T10VO> list = t10Service.getPAyRecordPeople(F0601);
        if (list.size() == 0){
            return new Result("没有充值记录");
        }
        return Result.success(list,"success");
    }
}
